<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>1.什么是数据代理</title>
    </head>

    <body>
        <!--
            数据代理:通过一个对象(obj1)代理对另一个对象中属性的操作(读/写)
        -->
        <script>
            let obj1 = {a:1};
            let obj2 = {b:2}
            Object.defineProperties(obj1,'b',{
                get() {
                    return obj2.b;
                },
                set(val) {
                    obj2.b = val;
                }
            })
            obj1.b = 3;
            console.log(obj2.b);
        </script>
    </body>
</html>
